package com.inibb.app.sftp.impl.jsch;

import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.jcraft.jsch.UserInfo;
/**
 * <p>Descriition: ssh user infomation ,this class used by JschSFTPConnection </p>
 * <p>Created by Nick.HT.Chu </p>
 * <p>Create Date 2006-6-16 14:24  </P>
 */

public class SSHPromptUserInfo implements UserInfo {
	String passwd;
	JTextField passwordField = (JTextField) new JPasswordField(20);
	public String getPassphrase() {
		return null;
	}

	public String getPassword() {
		return passwd;
	}

	public boolean promptPassword(String message) {
		Object[] ob = { passwordField };
		int result = JOptionPane.showConfirmDialog(null, ob, message,
				JOptionPane.OK_CANCEL_OPTION);
		if (result == JOptionPane.OK_OPTION) {
			passwd = passwordField.getText();
			return true;
		} else {
			return false;
		}
	}

	public boolean promptPassphrase(String message) {
		return true;
	}

	public boolean promptYesNo(String message) {
		/*
		Object[] options = { "yes", "no" };
		int foo = JOptionPane.showOptionDialog(null, message, "Warning",
				JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
				null, options, options[0]);
		return foo == 0;*/
		return true;
	}

	public void showMessage(String message) {
		JOptionPane.showMessageDialog(null, message);

	}

}
